package com.itttq.im.common.constant;

public class RedisConstant {
    /**
     * 记录用户ID集合，值为SET
     */
    private final static String USER_ONLINE = "user:online";
    private final static String GROUP_ID = "group:items";
    /**
     * 群组下所有用户列表，key为群组ID，值为用户ID的Set集合
     */
    private final static String GROUP_USERS = "group:users:%s";
    /**
     * 记录用户所在的服务器地址，便于互通。用Map保存
     */
    private final static String USER_SERVER = "user:server";
    /**
     * 记录所有的服务器，服务器启动的时候，会写入缓存当前服务器IP和端口
     */
    private final static String SERVER_HOSTS = "server:hosts";

    public static String getKeyUserOnline() {
        return USER_ONLINE;
    }

    public static String getKeyGroupId() {
        return GROUP_ID;
    }

    public static String getKeyUserServer() {
        return USER_SERVER;
    }

    public static String getKeyGroupUsers(String groupId) {
        return String.format(GROUP_USERS, groupId);
    }

    public static String getServerHosts() {
        return SERVER_HOSTS;
    }
}
